package com.yunhai.xc.util;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

import com.yunhai.xc.user.domain.User;

public class SubjectUtil {
	public static User getSubject() {
		Subject subject = SecurityUtils.getSubject();
		User user = (User) subject.getPrincipal();
		if (user != null) {
			return user;
		} else {
			user = new User();
			user.setId(-1);
		}
		return user;
	}

	public static Integer getSubjectId() {
		return getSubject().getId();
	}
}
